package com.tz.platform.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * 项目工具
 */
public class PorjectUtil {
	
	/**
	 * 取的当前项目的名称
	 * @return
	 */
	public static String getProjectName(){
		String path = PorjectUtil.class.getClassLoader().getResource("/").getPath();
		path = path.substring(0, path.lastIndexOf("WEB-INF")-1); 
		path = path.substring(path.lastIndexOf("webapps")+8);
		return path.toLowerCase();
	}
	
	/**
	 * 获取项目的网络路径
	 * @param request
	 * @return
	 */
	public static String getNetAddress(HttpServletRequest request){
		StringBuffer urlAll = request.getRequestURL(); // 全路径  http://localhost/platform/system/menu/tree.do
		String platformPath = request.getContextPath();
		String[] pathArr = urlAll.toString().split(platformPath);
		String basePath = pathArr[0] + platformPath;
		return basePath;
	}
	
}